home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / mus2v131.zip / RemovSng.cmd < prev    next >
OS/2 REXX Batch file  |  1996-02-08  |  3KB  |  120 lines

  1. /* ########################################################################
  2.  
  3.    This REXX script will communicate with a running Module Player that
  4.    support a Command Pipe.
  5.  
  6.    The Following commands are used
  7.       Query Song  -- Returns three lines, first is the file name, second is the
  8.                      index and third is the song title. They represent
  9.                      the currently playing song.
  10.       SongList EraseIndx -- Nukes 1 item in the list (by index)
  11.       Play Next -- Plays the next song
  12.  
  13.    ########################################################################
  14. */
  15. '@echo off'                       /* Don't echo commands */
  16. say " Module Player Remove Current Song From SongList V1.0                     Ethos"
  17.    call OpenPlayer
  18.    if Result <> 0 then do
  19.       say "Error" Error
  20.       return
  21.    end
  22.  
  23.    if CallPlayer("Query","Song","") <> 0 then do
  24.       say "Error" Error
  25.       return
  26.    end
  27.    Say "Currently Playing Song" Result.1 "'" || Result.3 || "'"
  28.  
  29.    if CallPlayer("SongList","EraseIndx",Result.2) <> 0 then do
  30.       say "Error" Error
  31.       return
  32.    end
  33.  
  34.    say "Erased from the Song List"
  35.  
  36.    if CallPlayer("Play","Next","") <> 0 then do
  37.       say "Error" Error
  38.       return
  39.    end
  40.    say "Playing Next Song"
  41. return
  42.  
  43. /* ########################################################################
  44.  
  45.    Function - CallPlayer
  46.    Eg - if (CallPlayer("Query","Song","") <> 0) then Error
  47.  
  48.    Description - This procedure sends a command message to the player.
  49.                  An error is returned if the player doesn't understand
  50.                  the message or something else is wrong.
  51.                    Result - A stem containing each line of the result
  52.                    Error - Global error code
  53.  
  54.    ########################################################################
  55. */
  56. CallPlayer: procedure expose Result. Player Error
  57.    parse arg Command, SCommand, Arg
  58.  
  59.    Error = ""
  60.    Result.0 = 0
  61.  
  62.    /* Player not loaded */
  63.    if (Player = "") then do
  64.       Error = "Player not Inited"
  65.       return 1
  66.    end
  67.  
  68.    call lineout Player,Command SCommand Arg
  69.  
  70.    /* Get all the results */
  71.    do while (1)
  72.       Line = linein(Player)
  73.  
  74.       /* Error or something */
  75.       if (pos("!!",Line) = 1) then do
  76.          if (Line = "!! OK") then
  77.             return 0
  78.          Error = substr(Line,4)
  79.          return 1
  80.       end;
  81.  
  82.       Result.0 = Result.0 + 1
  83.       I = Result.0
  84.       Result.I = Line
  85.    end
  86.  
  87. return 0
  88.  
  89. /* ########################################################################
  90.  
  91.    Function - OpenPlayer
  92.    Eg - call OpenPlayer
  93.  
  94.    Description - This procedure opens the pipe and sets the following:
  95.                    Player - The name of the pipe - \pipe\Player
  96.                    Version - The pipe comminication version
  97.                    Type - The program running on the other end, 'Text UI'
  98.                    Error - Global Error Code
  99.  
  100.    ########################################################################
  101. */
  102. OpenPlayer:procedure expose Player Version Type Error
  103.    Error = ""
  104.  
  105.    Result = Stream("\pipe\ModulePlayer","C","OPEN");
  106.    if (Result <> "READY:") then do
  107.       Error = "Unable to communicate with the  Player, is it running?"
  108.       Player = ""
  109.       return 1
  110.    end
  111.    Player = "\pipe\ModulePlayer"
  112.  
  113.    /* Get the version */
  114.    S = linein(Player)
  115.    parse var S 'V' Version .
  116.    Type = linein(Player)
  117. return 0
  118.  
  119.  
  120.